 <style lang="less" scoped>
.chart-table {
  color: #fff;
  border-collapse: collapse;
  .chart-colums {
    cursor: pointer;
    border: 1px solid #145a7b;
  }
  .ivu-table-cell {
    padding: 10px 2px;
  }
}

.realTime-title {
  border-left: 3px solid #4588b3;
  div {
    font-size: 18px;
    margin-left:10px;
    color: #fff;
    padding: 5px;
    padding-left: 40px;
    background-color: #0c2461;
    border:1px solid #0a3d62;
  }
}
.today-fire-title {
  color: #fff;
  font-size: 18px;
  text-align: center;
  padding: 10px;
}
.today-fire-count {
  font-size: 20px;
  text-align: center;
  padding: 5px;
}
</style>

<template>
  <div>
    <div>
      <div class="realTime-title">
        <div>今日警情</div>
      </div>
      <div>
        <Row>
          <Col span="12">
            <div class="today-fire-title">
              <span class="ivu-tag-dot-inner" style="background-color:#f5f24f;"></span>火警单位数
            </div>
            <div class="today-fire-count" style="color:#f5f24f;">{{todayAlarmSum.shop_count}}</div>
          </Col>
          <Col span="12">
            <div class="today-fire-title">
              <span class="ivu-tag-dot-inner" style="background-color:#dc2251;"></span>火警数
            </div>
            <div class="today-fire-count" style="color:#dc2251;">{{todayAlarmSum.alarm_count}}</div>
          </Col>
        </Row>
      </div>
      <div class="realTime-title">
        <div>今日天气</div>
      </div>
      <div style="text-align:center;">
        <iframe
          width="200"
          scrolling="no"
          height="120"
          frameborder="0"
          allowtransparency="true"
          src="//i.tianqi.com/index.php?c=code&id=19&color=%23FFFFFF&icon=1&temp=0&num=1&site=12"
        ></iframe>
      </div>

      <div style="max-height:260px;
  overflow-y: auto;">
        <table class="chart-table" cellspacing="0" cellpadding="0" border="0" style="width: 100%">
          <colgroup>
            <col width="170">
            <col width="170">
            <col width="171">
          </colgroup>
          <thead>
            <tr class="chart-colums" style="background:#0d60ca;">
              <th>
                <div class="ivu-table-cell">
                  <span>火警单位名称</span>
                </div>
              </th>
              <th>
                <div class="ivu-table-cell">
                  <span class>火警时间</span>
                </div>
              </th>
              <th>
                <div class="ivu-table-cell">
                  <span class>火警地址</span>
                </div>
              </th>
            </tr>
          </thead>
          <tbody class="ivu-table-tbody">
            <tr
              class="ivu-table-row chart-colums"
              v-for="(item,index) in tableData"
              :key="index"
              @click="locateAlarm(item.lat,item.lng)"
            >
              <td class>
                <div class="ivu-table-cell" style="text-align:center;">
                  <span>{{item.shop_name}}</span>
                </div>
              </td>
              <td class>
                <div class="ivu-table-cell" style="text-align:center;">
                  <span>{{item.alarm_time}}</span>
                </div>
              </td>
              <td class>
                <div class="ivu-table-cell" style="text-align:center;">
                  <span>{{item.addr}}</span>
                </div>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    dataSource: {
      type: Object,
      default: function() {
        return {};
      }
    },
    tableData: {
      type: Array,
      default: function() {
        return [];
      }
    }
  },
  data() {
    return {
      todayAlarmSum: { alarm_count: 0, shop_count: 0 }
     
    };
  },
  watch: {
    dataSource(curVal, oldVal) {
      if (this.dataSource.alarm_count) {
        this.todayAlarmSum.alarm_count = this.dataSource.alarm_count;
      }
      if (this.dataSource.shop_count) {
        this.todayAlarmSum.shop_count = this.dataSource.shop_count;
      }
    }
  },
  mounted() {},
  methods: {
    locateAlarm(lat,lng){
      this.$emit('on-locate-alarm', {lat:lat,lng:lng})
    }
  }
};
</script>
